package com.hz.ruoyifarmbase.baseinfo.service.impl;

import com.hz.ruoyifarmbase.basedata.service.impl.AgrBaseWorkerServiceImpl;
import com.hz.ruoyifarmbase.basedata.service.impl.AgrGermTypeServiceImpl;
import com.hz.ruoyifarmbase.baseinfo.domain.AgrBasePlots;
import com.hz.ruoyifarmbase.baseinfo.domain.vo.AgrFistPageCountBaseVo;
import com.hz.ruoyifarmbase.baseinfo.service.AgrFistPageCountService;
import com.hz.ruoyifarmbase.farm.service.impl.AgrBaseBatchServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: zjk
 * @Date: 2025/3/14 18:34
 * @Description: TODO
 */
@Service
public class AgrFistPageCountServiceImpl implements AgrFistPageCountService {
    @Autowired
    private AgrBasePlotsServiceImpl agrBasePlotsService;
    @Autowired
    private AgrBaseBatchServiceImpl agrBaseBatchService;
    @Autowired
    private AgrGermTypeServiceImpl agrGermTypeService;
    @Autowired
    private AgrBaseWorkerServiceImpl agrBaseWorkerService;
    @Override
    public AgrFistPageCountBaseVo getList() {

        AgrFistPageCountBaseVo agrFistPageCountBaseVo = new AgrFistPageCountBaseVo();
        List<AgrBasePlots> plotsList =agrBasePlotsService.selectAgrBasePlotsList(null);
        agrFistPageCountBaseVo.setPlotsCountT(plotsList.stream().filter(agrBasePlots -> agrBasePlots.getPlotsType() == 0l).count());
        agrFistPageCountBaseVo.setPlotsCountP(plotsList.stream().filter(agrBasePlots -> agrBasePlots.getPlotsType() == 1l).count());
        agrFistPageCountBaseVo.setPlotsArea(plotsList.stream()
                .mapToLong(AgrBasePlots::getPlotsArea)
                .sum());


        agrFistPageCountBaseVo.setWorkerCount(agrBaseWorkerService.countWorker());
        agrFistPageCountBaseVo.setBatchCount(agrBaseBatchService.countBatch(null));
        agrFistPageCountBaseVo.setBatchIng(agrBaseBatchService.countBatch(0));
        agrFistPageCountBaseVo.setBatchEnd(agrBaseBatchService.countBatch(2));
        agrFistPageCountBaseVo.setBatchNot(agrBaseBatchService.countBatch(1));
        agrFistPageCountBaseVo.setTypeCount(agrGermTypeService.countAgrGermType());
        return agrFistPageCountBaseVo;
    }
}
